/*
 * Copyright (C) 2010, JDevelopers (jdevelopers@my-pages.org) 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0 
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 */
package org.jdevelopers.xarf;

import java.io.Serializable;
import java.util.List;
import java.util.Vector;

/**
 * Object for storing the properties of a parsed report into the result report.
 * 
 * @author Marcel Hartwig
 * @version 0.2
 * @since JXarfValidator 0.1
 */
public abstract class XarfReportProperty implements Serializable {
	
	/**
     * ID for serializing the object.
     */
    private static final long serialVersionUID = 1264202676667704106L;
    private String propertyName;
	private List<String> propertyValues = null;
	private EXarfPropertyFormatType propertyFormatType;
	
	/**
	 * Constructor for the XarfReportProperty.
	 * 
	 * @param propertyName the name of the property.
	 * @param propertyValues the values of the property.
	 * @param propertyFormatType the format type of the property.
	 */
	public XarfReportProperty(String propertyName, List<String> propertyValues, EXarfPropertyFormatType propertyFormatType) {
		this.propertyName = propertyName;
		this.propertyValues = propertyValues;
		this.propertyFormatType = propertyFormatType;
	}
	
	/**
	 * Constructor for the XarfReportProperty.
	 */
	public XarfReportProperty() {
	}
	
	/**
	 * Returns the name of the property.
	 * 
	 * @return the propertyName.
	 */
	public String getPropertyName() {
		return propertyName;
	}
	
	/**
	 * Sets the name of the property.
	 * 
	 * @param propertyName the name of the property to set.
	 */
	protected void setPropertyName(String propertyName) {
		this.propertyName = propertyName;
	}
	
	/**
	 * Returns the value of the property.
	 * 
	 * @return the value of the property.
	 */
	public List<String> getPropertyValue() {
		return propertyValues;
	}
	
	/**
	 * Sets the value of the property.
	 * 
	 * @param propertyValue the value of the property to set.
	 */
	protected void setPropertyValue(List<String> propertyValues) {
		this.propertyValues = propertyValues;
	}
	
	/**
	 * Method for adding a property value.
	 * 
	 * @param propertyValue the property value to be added.
	 */
	protected void addPropertyValue(String propertyValue) {
		if(this.propertyValues == null) {
			this.propertyValues = new Vector<String>();
		}
		this.propertyValues.add(propertyValue);
	}
	
	/**
	 * Method for adding multiple property values.
	 * 
	 * @param propertyValues the property values to be added.
	 */
	protected void addAllPropertyValues(List<String> propertyValues) {
		if(this.propertyValues == null) {
			this.propertyValues = new Vector<String>();
		}
		this.propertyValues.addAll(propertyValues);
	}
	
	/**
	 * Returns the format type of the property.
	 *  
	 * @return the format type of the property.
	 */
	public EXarfPropertyFormatType getPropertyFormatType() {
		return propertyFormatType;
	}

	/**
	 * Sets the format type of the property.
	 * 
	 * @param propertyFormatType the propertyFormatType to set.
	 */
	public void setPropertyFormatType(EXarfPropertyFormatType propertyFormatType) {
		this.propertyFormatType = propertyFormatType;
	}

	/**
	 * Provides the String representation of the <code>XarfReportProperty</code>.
	 */
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(propertyName).append(": ").append(propertyValues.toString().replaceAll("[\\[\\]]", ""));
		return sb.toString();
	}
	

}
